<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="" />
    <style>
      li {
        border: 1px solid lightblue;
      }
    </style>
  </head>
  <body>
    <button id="btn">设置列表项尺寸</button>
    <hr />
    <ul>
      <li>列表项1</li>
      <li>列表项2</li>
      <li>列表项3</li>
      <li>列表项4</li>
    </ul>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <script>
      $(function () {
        $('#btn').click(function () {
          $('li').height(function (index, oldheight) {
            console.log('函数参数', index, oldheight)
            function pointerHeight(i, h) {
              $('li').eq(i).height(h)
            }
            switch (index) {
              case 0:
                pointerHeight(index, 20)
                break
              case 1:
                pointerHeight(index, 40)
                break
              case 2:
                pointerHeight(index, 60)
                break
              case 3:
                pointerHeight(index, 80)
                break
            }
          })
        })
      })
    </script>
  </body>
</html>
